package br.com.scv.logicImp;

import java.util.ArrayList;
import java.util.List;

import br.com.scv.dao.VagaDao;
import br.com.scv.daoImp.VagaDaoImp;
import br.com.scv.exception.DAOException;
import br.com.scv.exception.RNException;
import br.com.scv.logic.VagaLogic;
import br.com.scv.model.Vaga;

public class VagaLogicImp implements VagaLogic {

	private VagaDao dao;
	
	@Override
	public void salvar(Vaga vaga) throws RNException {
		if(vaga.getSetor() == null | vaga.getSetor().equals("")){
			throw new RNException("Favor informar Setor!");
		}else{
			dao = new VagaDaoImp();
			try {
				dao.salvar(vaga);
			} catch (DAOException e) {
				throw new RNException("Erro ao salvar..." + e.getMessage());
			}
		}
		
	}

	@Override
	public void editar(Vaga vaga) throws RNException {
		dao = new VagaDaoImp();
		try {
			dao.editar(vaga);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		
	}

	@Override
	public void excluir(Vaga vaga) throws RNException {
		dao = new VagaDaoImp();
		try {
			dao.excluir(vaga);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	@Override
	public List<Vaga> listar() throws RNException {
		dao = new VagaDaoImp();
		List<Vaga> vagas = new ArrayList<Vaga>();
		try {
			vagas = dao.listar();
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return vagas;
	}

}
